/**
 *	Define the common type and tools.
 * */

#include <vector>
#include <string>
#include <complex>

#include <boost/cstdint.hpp>
#include <boost/rational.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>
#include <boost/unordered_map.hpp>
#include <boost/unordered_set.hpp>


#ifndef KUAIMISC_TYPEDEF_H
#define KUAIMISC_TYPEDEF_H

namespace kuai {

	typedef boost::uint_fast16_t		Index;
	typedef boost::int_fast16_t			Integer;

	typedef double						RealNumber;

	typedef boost::uint8_t				Index8;
	typedef boost::uint16_t				Index16;
	typedef boost::uint32_t				Index32;
	typedef boost::uint64_t				Index64;

	typedef boost::int8_t				Integer8;
	typedef boost::int16_t				Integer16;
	typedef boost::int32_t				Integer32;
	typedef boost::int64_t				Integer64;

	typedef float						RealNumber32;
	typedef double						RealNumber64;

	typedef void*						Handle;
	typedef char						Char;
	typedef unsigned char				Byte;

	typedef boost::rational<Integer>	RationalNumber;
	typedef boost::rational<Integer8>	RationalNumber16;
	typedef boost::rational<Integer16>	RationalNumber32;
	typedef boost::rational<Integer32>	RationalNumber64;
	typedef boost::rational<Integer64>	RationalNumber128;

	typedef std::complex<RealNumber>	ComplexNumber;
	typedef std::complex<RealNumber32>	ComplexNumber64;
	typedef std::complex<RealNumber64>	ComplexNumber128;

	enum {
		INVALID_INDEX = Index(-1)
	};

	typedef std::string 				String;

	template<typename T>
	inline bool isZero(const std::vector<T>& v0) {
		for (size_t i = 0; i < v0.size(); ++i) {
			if (v0[i] != 0) {
				return false;
			}
		}
		return true;
	}

	#define TreeMap						std::map
	#define TreeSet						std::set
	#define TreeMultiMap				std::multimap
	#define TreeMultiSet				std::multiset

	#define HashMap						boost::unordered_map
	#define HashSet						boost::unordered_set
	#define HashMultiMap				boost::unordered_multimap
	#define HashMultiSet				boost::unordered_multiset

	#define SharedPtr					boost::shared_ptr

	typedef boost::noncopyable			Noncopyable;

	#define arrayLength(a) 				(sizeof(a) / sizeof(a[0]))

	#define Me 							(*this)
}


#endif
